<?php
class doom_ctrl_template {

    public $request;

    public $response;

    public $type;

    function __construct(&$request, &$response) {

        $this->request = $request;
        $this->response = $response;
    }

    public function load($templateName, $type) {

        $templateFn = doom_config::$PROJECT_BASE_DIR . 'view/' . $type . '/' . $templateName . '.tpl.php';
        if (isset($this->response->data) && is_array($this->response->data)) {
            $data = $this->response->data;
            foreach ($data as $k => $v) {
                $$k = $v;
            }
        }
        if (file_exists($templateFn)) {
            require $templateFn;
        } else {
            echo "error:template not found:$type/$templateName, File not found: $templateFn";
        }
    }
}